class Cliente < ActiveRecord::Base
  has_many :tarjetas, :dependent => :destroy
  has_many :direccions, :dependent => :destroy
  has_many :orden_servicios, :dependent => :destroy
  accepts_nested_attributes_for :tarjetas, :allow_destroy => true
  accepts_nested_attributes_for :direccions, :allow_destroy => true
  
  validates_presence_of     :nombre
  validates_length_of       :nombre,    :maximum => 50
  validates_presence_of     :apellido
  validates_length_of       :apellido,    :maximum => 50
  validates_presence_of     :fecha_nac
  validates_presence_of     :correo
  validates_length_of       :correo,    :maximum => 100
  validates_uniqueness_of   :correo, :message => "Ya Ud se encuentra registrado"
  validates_format_of       :correo,
  	:with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :message => "Correo Invalido"
  	
end
